﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DigitMatrix.Business
{
    public class Player
    {
        int PORT = 0;
        private IntPtr _plHandle;
        bool isOpen = false;
        public Player(IntPtr plHandle,IntPtr wndHandle )
        {
            _plHandle = plHandle;
            HikPlayer.Hik_PlayM4_SetVolume(PORT, 0xFFFF);
            HikPlayer.Hik_PlayM4_SetFileEndMsg(PORT, wndHandle, HikPlayer.WM_FILE_END);
            HikPlayer.Hik_PlayM4_SetEncChangeMsg(PORT, wndHandle, HikPlayer.WM_ENC_CHANGE);
        }
        public  void Play(string m_strPlayFileName)
        {
            //开始播放
            if (isOpen)
            {
                HikPlayer.Hik_PlayM4_CloseFile(PORT);
            }
            HikPlayer.Hik_PlayM4_OpenFile(PORT, m_strPlayFileName);
            HikPlayer.Hik_PlayM4_Play(PORT, _plHandle);//this.Handle);  
            //播放声音
            HikPlayer.Hik_PlayM4_PlaySound(PORT);
            isOpen = true;
        }
        public void Play()
        {
            HikPlayer.Hik_PlayM4_Play(PORT, _plHandle);
        }
        public void Pause()
        {
            HikPlayer.Hik_PlayM4_Pause(PORT, true);
        }

        public void Recover()
        {
            HikPlayer.Hik_PlayM4_Pause(PORT, false);
        }
        public void Slow()
        {
            HikPlayer.Hik_PlayM4_Slow(PORT);
        }
        public void Fast()
        {
            HikPlayer.Hik_PlayM4_Fast(PORT);
        }
        public void Stop()
        {
            HikPlayer.Hik_PlayM4_Stop(PORT);
        }
        public void Close()
        {
            HikPlayer.Hik_PlayM4_CloseFile(PORT);
            HikPlayer.Hik_PlayM4_Stop(PORT);
        }
    }
}
